/**
 *  Copyright (C) 2008-2013  Telosys project org. ( http://www.telosys.org/ )
 *
 *  Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *          http://www.gnu.org/licenses/lgpl.html
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.telosys.persistence.impl;

import org.telosys.common.data.BeanList;
import org.telosys.persistence.Query;


/**
 * Standard implementation of ListQuery
 * 
 * @author Laurent GUERIN
 *  
 */
public class QueryImpl<T> extends QueryAncestor implements Query<T>
{
	private Class<T>   _entityBeanClass  = null;
	
    //--- SQL request to SELECT the elements of the list
    private String     _SqlSelect    = "";

    //--- SQL request to delete the elements of the list
    private String     _SqlDelete    = "";

    //--- SQL request to count the elements of the list
    private String     _SqlCount     = "";

    //-----------------------------------------------------------------------------
    // CONSTRUCTOR(S)
    //-----------------------------------------------------------------------------
    /**
     * Constructor for a standard LIST QUERY object
     * @param entityBeanClass
     * @param iParamCount
     * @param sSqlSelectData
     * @param sSqlSelectCount
     * @param sSqlDelete
     */
    public QueryImpl(Class<T> entityBeanClass, int iParamCount, String sSqlSelectData, String sSqlSelectCount, String sSqlDelete)
    {
    	super(iParamCount);
    	_entityBeanClass = entityBeanClass ;
        _SqlSelect = sSqlSelectData;
        _SqlCount  = sSqlSelectCount;
        _SqlDelete = sSqlDelete;
    }
    
    public Class<T> getEntityBeanClass()
    {
        return _entityBeanClass;
    }

    public BeanList<T> createList()
    {
		BeanList<T> list = new BeanList<T>( _entityBeanClass );
    	
        return list;
    }

    
    //-----------------------------------------------------------------------------
    // INTERFACE IMPLEMENTATION
    //-----------------------------------------------------------------------------
    
    //-----------------------------------------------------------------------------
    /* (non-Javadoc)
     * @see org.objectweb.telosys.dal.dao.ListQuery#getSqlSelect()
     */
    public String getSqlSelect()
    {
        return _SqlSelect;
    }

    //-----------------------------------------------------------------------------
    /* (non-Javadoc)
     * @see org.objectweb.telosys.dal.dao.ListQuery#getSqlDelete()
     */
    public String getSqlDelete()
    {
        return _SqlDelete;
    }

    //-----------------------------------------------------------------------------
    /* (non-Javadoc)
     * @see org.objectweb.telosys.dal.dao.ListQuery#getSqlCount()
     */
    public String getSqlCount()
    {
        return _SqlCount;
    }

}